package com.woniu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniu.mapper.CoursesCardMapper;
import com.woniu.pojo.ClassChange;
import com.woniu.mapper.ClassChangeMapper;
import com.woniu.pojo.CoursesCard;
import com.woniu.service.IClassChangeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.vo.cardVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.LinkedList;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaohuang
 * @since 2022-10-12
 */
@Service
public class ClassChangeServiceImpl extends ServiceImpl<ClassChangeMapper, ClassChange> implements IClassChangeService {
    @Autowired
    private ClassChangeMapper classChangeMapper;
    @Autowired
    private CoursesCardMapper coursesCardMapper;
    @Override
    public ClassChange byTimetableIdAndCardId(String timetableId, String cardId) {
        QueryWrapper<CoursesCard> wrapper = new QueryWrapper<>();
        wrapper.eq("timetable_id", timetableId);
        wrapper.eq("card_id",cardId);
        CoursesCard coursesCard = coursesCardMapper.selectOne(wrapper);
        if (coursesCard == null){
            return null;
        }
        String classChangeId = coursesCard.getClassChangeId();
        ClassChange classChange = classChangeMapper.selectById(classChangeId);
        return classChange;
    }
}
